Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support java.util.Optional as return type of mapper method #799

Merged
merged 7 commits into from Mar 16, 2018

Conversation

kazuki43zoo
Copy link
Member

@kazuki43zoo kazuki43zoo commented Oct 8, 2016

I know this fix is ad hoc. However, i want to provide early this feature for Java 8 users. I will improve this feature at 3.5 or later version.

This fix allow following method definition:

public interface UserMapper {

  @Select("select * from users where id = #{id}")
  Optional<User> findOne(Integer id);

}

Please review.

@kazuki43zoo kazuki43zoo force-pushed the support-optional-mapper-method branch from 4eca279 to d4099b7 Compare October 8, 2016 08:10
@kazuki43zoo kazuki43zoo changed the title Support java.util.Optionl as return type of mapper method Support java.util.Optional as return type of mapper method Oct 8, 2016
@kazuki43zoo kazuki43zoo force-pushed the support-optional-mapper-method branch from d4099b7 to 452ba6b Compare October 8, 2016 11:53
@harawata
Copy link
Member

Hi,

I wrote a patch to support Optional, a while ago.
Here's the branch...
https://github.com/harawata/mybatis-3/commits/optional
... and test cases.
https://github.com/harawata/mybatis-optional-test

I consider it is still under the committers' review (@eddumelendez seemed to like it), but I would appreciate if you could check it out and let me know what you think.

Thank you,
Iwao

@kazuki43zoo
Copy link
Member Author

Hi @harawata, it's great !! I will confirm your patch at later and leave comments if needed.

Thanks !

# Conflicts:
#	src/main/java/org/apache/ibatis/binding/MapperMethod.java
@harawata
Copy link
Member

Hi @kazuki43zoo ,

Do you mind if I add some commits to this PR?

@harawata harawata reopened this Jan 11, 2018
@harawata
Copy link
Member

@kazuki43zoo , I have added a few commits (hope it was OK!).

@jeffgbutler @christianpoitras
It is very simple, but satisfies the minimum requirement we discussed on #228 , I think.
Please take a look when you have time.

To reduce the noise, it's better to add w=1 when reviewing the diff.
https://github.com/mybatis/mybatis-3/pull/799/files?w=1

@kazuki43zoo
Copy link
Member Author

@harawata Thanks for your improvements. I feel your changes are good!

@alexhilman
Copy link

Hello, I'm curious: is there a timeline for the acceptance and release of this pull request?

@christianpoitras
Copy link
Member

All changes seem fine. @harawata, you can merge the pull request.

@harawata
Copy link
Member

harawata commented Mar 7, 2018

Thanks @christianpoitras !
I will merge it as soon as we release 3.4.6 .

@alexhilman
Copy link

Thanks @christianpoitras and @harawata - I am looking forward to using it.

pulllock pushed a commit to pulllock/mybatis-3 that referenced this pull request Oct 19, 2023
…er-method

Support java.util.Optional as return type of mapper method
pulllock pushed a commit to pulllock/mybatis-3 that referenced this pull request Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve a feature or add a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants